package thread;

public class Demo18 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1结束！");
        });
        Thread t2 = new Thread(() ->{
            try {
                t1.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("t2结束！");
        });
        t1.start();
        t2.start();
        System.out.println("主线程结束!");
    }
}
